package com.xbongbong.saas.model;

import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.wrap.IModel;
import com.xbongbong.saas.domain.entity.RefundUserEntity;
import com.xbongbong.saas.domain.entity.UserTeamEntity;
import org.elasticsearch.action.support.WriteRequest;

import java.util.List;
import java.util.Map;

/**
 * @author feng.zheng
 * @version v1.0
 * @date 2019/1/25 10:18
 * @since v1.0
 */
public interface RefundUserModel extends IModel<RefundUserEntity> {

    /**
     * 获取符合查询条件的记录
     *
     * @param param 查询条件
     * @return java.util.List<com.xbongbong.saas.domain.entity.CustomerUserEntity>
     * @author feng.zheng
     * @date 2019/2/16 14:22
     */
    @Override
    List<RefundUserEntity> findEntitys(Map<String, Object> param);

    /**
     * 保存实体
     *
     * @param refundUserEntity 退货退款协同人团队实体
     * @return java.lang.Integer
     * @throws XbbException 数据库异常
     * @author feng.zheng
     * @date 2019/2/14 16:42
     */
    Integer save(RefundUserEntity refundUserEntity) throws XbbException;


    /**
     * 删除某公司某合同对应的销售团队
     *
     * @param corpid     公司ID
     * @param contractId 合同ID
     * @return 0失败，1成功
     * @author kaka
     * @date 2018-01-04
     */


    /**
     * 批量解散团队依据客户id
     *
     * @param corpid
     * @param customerIdList
     */
    void disbandedTeamByCustomerId(String corpid, List<Long> customerIdList) throws XbbException;

    /**
     * 删除合同团队
     *
     * @param contractUser
     */
    void delete(RefundUserEntity contractUser) throws XbbException;

    /**
     * 查询协同团队基础列表
     *
     * @param map 参数
     * @return 团队
     */
    List<UserTeamEntity> findBaseEntitys(Map<String, Object> map);

    /**
     * 批量删除
     *
     * @param refundIdIn   退货退款合同id
     * @param corpid       公司id
     * @return java.lang.Integer
     * @throws XbbException 业务异常
     * @author 吴峰
     * @date 2019/3/13 16:20
     */
    Integer deleteBatchByRefundIdIn(List<Long> refundIdIn, String corpid) throws XbbException;

    /**
     * 获取协同团队的业务数据
     *
     * @param corpid 公司id
     * @param isMain 负责或协同
     * @param userId 用户id
     * @return List<Long>
     * @author long.rao
     * @date 2019-03-20 15:34
     */
    List<Long> getDataIdList(String corpid, Integer isMain, List<String> userId);

    void insertBatch(List<RefundUserEntity> refundUserEntityList, boolean isImport) throws XbbException;

    /**
     * 退货退款关联用户实体
     *
     * @param key    主键
     * @param corpid 公司ID
     * @return
     */
    RefundUserEntity getByKey(Long key, String corpid);

    void batchUpdateByUserIdIn(String corpid, List<Long> dataIdIn, List<UserTeamEntity> teamEntityList, Integer isMain, Integer del) throws XbbException;

    void batchUpdateByUserIdIn(String corpid, List<Long> dataIdIn, List<UserTeamEntity> teamEntityList, Integer isMain, Integer del, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException;

    void deleteBatchUser(List<RefundUserEntity> refundUserEntityList, String corpid, Integer del) throws XbbException;

    /**
     * 批量剔除团队
     * @param corpid
     * @param removeIdList 客户团队表idList
     */
    Map<Long, String> batchDeleteById(String corpid, List<Long> removeIdList) throws XbbException;

    List<RefundUserEntity> getByRefundId(String corpid, Long id);

    void updateBatch(List<RefundUserEntity> refundUserEntityList, String corpid) throws XbbException;

    /**
     * 编辑团队成员标签
     *
     * @param refundUserEntity
     */
    void editLabel(RefundUserEntity refundUserEntity) throws XbbException;

    /**
     * 更新协同人可编辑权限
     *
     * @param refundUserEntity
     */
    void updateEditFormPer(RefundUserEntity refundUserEntity) throws XbbException;

    /**
     * 更新团队协同人信息和协同人可编辑权限
     *
     * @param corpid
     * @param idIn
     * @param updateUserToCoTeamList
     * @param coopUser
     * @param needThrow
     */
    void batchUpdateCoAndPerByUserIdIn(String corpid, List<Long> idIn, List<UserTeamEntity> updateUserToCoTeamList, Integer coopUser, boolean needThrow) throws XbbException;

    void batchUpdateCoAndPerByUserIdIn(String corpid, List<Long> idIn, List<UserTeamEntity> teamEntityList, Integer isMain, boolean needThrow, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException;
}
